package com.epoint.androidphone.mobileoa.ui.contacts;

import java.util.Map;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.epoint.androidphone.R;
import com.epoint.androidphone.mobileoa.ui.superview.SuperPhonePage;
import com.epoint.androidmobile.bizlogic.common.PhoneService;
import com.epoint.androidmobile.core.control.AlertUtil;
/**
 * @author liyc
 * @time 2013-5-9 下午10:26:34
 * @annomation 
 */
public class ContactsDetailView extends SuperPhonePage {

	ImageButton ibHead;
	TextView tvName,tvOuName,tvTitleZy,tvMobile,tvTeleOffice,tvTeleHome,tvEmail;
	LinearLayout llMobile,llTeleOffice,llTeleHome,llMail;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addContentViewAndTitle(R.layout.contactsdetailview, "详细信息");
		ibHead = (ImageButton) findViewById(R.id.ibHead);
		tvName = (TextView) findViewById(R.id.tvName);
		tvOuName = (TextView) findViewById(R.id.tvOuName);
		tvTitleZy = (TextView) findViewById(R.id.tvTitleZY);
		tvMobile = (TextView) findViewById(R.id.tvMobile);
		tvTeleOffice = (TextView) findViewById(R.id.tvTeleOffice);
		tvTeleHome = (TextView) findViewById(R.id.tvTeleHome);
		tvEmail = (TextView) findViewById(R.id.tvMail);
		llMobile = (LinearLayout) findViewById(R.id.llMobile);
		llTeleOffice = (LinearLayout) findViewById(R.id.llTeleOffice);
		llTeleHome = (LinearLayout) findViewById(R.id.llTeleHome);
		llMail = (LinearLayout) findViewById(R.id.llMail);
		llMobile.setOnClickListener(this);
		llTeleOffice.setOnClickListener(this);
		llTeleHome.setOnClickListener(this);
		llMail.setOnClickListener(this);

		String userguid = getIntent().getStringExtra("userguid");
		Map<String, String> map = dbUtil.getUserDetailByUserguid(userguid);
		tvName.setText(map.get("displayname"));
		tvOuName.setText(map.get("ouname"));
		tvTitleZy.setText(map.get("title"));
		tvMobile.setText(map.get("mobile"));
		tvTeleOffice.setText(map.get("teleoffice"));
		tvTeleHome.setText(map.get("telehome"));
		tvEmail.setText(map.get("mail"));

		if(map.get("sex").equals("女"))
		{
			ibHead.setImageResource(R.drawable.img_woman);
		}
	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		if (v==llMobile) {
			PhoneService.callAndMsg(this, "手机号", tvMobile.getText().toString());
		}
		else if (v==llTeleOffice) {
			PhoneService.callAndMsg(this, "办公电话", tvTeleOffice.getText().toString());
		}
		else if (v==llTeleHome) {
			PhoneService.callAndMsg(this, "家庭电话", tvTeleHome.getText().toString());
		}
		else if(v==llMail)
		{
			if(tvEmail.getText().toString().trim().length()==0)
			{
				return;
			}
			AlertUtil.showMsgClose(this, "邮件", tvEmail.getText().toString());
		}
	}
	
}
